import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import {fileURLToPath, URL} from 'node:url'
import svgLoader from 'vite-svg-loader'

export default defineConfig({
    plugins: [vue(), svgLoader()],
    base: './',
    build: {
        lib: {
            entry: fileURLToPath(new URL('./packages/index.js', import.meta.url)),
            name: 'schezhi-ui',
            fileName: (format) => `schezhi-ui.${format}.js`
        },
        rollupOptions: {
            external: ['vue', 'element-plus','lodash','codemirror','echarts','axios','pinyin-match','nprogress','svelte','sortablejs','js-beautify','tinymce'],
            output: {
                globals: {
                    vue: 'Vue',
                    'element-plus': 'ElementPlus'
                }
            }
        }
    },
    resolve: {
        extensions: ['.vue', '.js'],
        alias: {
            '@': fileURLToPath(new URL('./src', import.meta.url))
        }
    }
})
